home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tk_CreateFileHandler(3)Tk Library Procedures
-
-
-
- _________________________________________________________________
-
- NAME
- Tk_CreateFileHandler, Tk_DeleteFileHandler - associate pro-
- cedure callback with a file or device
-
- SYNOPSIS
- #include <tk.h>
-
- Tk_CreateFileHandler(_i_d, _m_a_s_k, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a)
-
- Tk_DeleteFileHandler(_i_d)
-
- ARGUMENTS
- int _i_d (in) Integer identifier for
- an open file or device
- (such as returned by
- open system call).
-
- int _m_a_s_k (in) Conditions under which
- _p_r_o_c should be called:
- OR-ed combination of
- TK_READABLE,
- TK_WRITABLE, and
- TK_EXCEPTION.
-
- Tk_FileProc *_p_r_o_c (in) Procedure to invoke
- whenever the file or
- device indicated by _i_d
- meets the conditions
- specified by _m_a_s_k.
-
- ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary one-word
- value to pass to _p_r_o_c.
- _________________________________________________________________
-
-
- DESCRIPTION
- Tk_CreateFileHandler arranges for _p_r_o_c to be invoked in the
- future whenever I/O becomes possible on a file or an excep-
- tional condition exists for the file. The file is indicated
- by _i_d, and the conditions of interest are indicated by _m_a_s_k.
- For example, if _m_a_s_k is TK_READABLE, then _p_r_o_c will be
- called when the file is readable. The callback to _p_r_o_c is
- made by Tk_DoOneEvent, so Tk_CreateFileHandler is only use-
- ful in programs that dispatch events through Tk_DoOneEvent
- or through other Tk procedures that call Tk_DoOneEvent, such
- as Tk_MainLoop.
-
- _P_r_o_c should have arguments and result that match the type
- Tk_FileProc:
- typedef void Tk_FileProc(
-
-
-
- Tk 1
-
-
-
-
-
-
- Tk_CreateFileHandler(3)Tk Library Procedures
-
-
-
- ClientData _c_l_i_e_n_t_D_a_t_a,
- int _m_a_s_k);
- The _c_l_i_e_n_t_D_a_t_a parameter to _p_r_o_c is a copy of the _c_l_i_e_n_t_D_a_t_a
- argument given to Tcl_CreateFileHandler when the callback
- was created. Typically, _c_l_i_e_n_t_D_a_t_a points to a data struc-
- ture containing application-specific information about the
- file. _M_a_s_k is an integer mask indicating which of the
- requested conditions actually exists for the file; it will
- contain a subset of the bits in the _m_a_s_k argument to
- Tcl_CreateFileHandler.
-
- There may exist only one handler for a given file at a given
- time. If Tk_CreateEventHandler is called when a handler
- already exists for _i_d, then the _m_a_s_k, _p_r_o_c, and _c_l_i_e_n_t_D_a_t_a
- for the new call to Tk_CreateEventHandler replace the infor-
- mation that was previously recorded.
-
- Tk_DeleteFileHandler may be called to delete the file
- handler for _i_d; if no handler exists for the file given by
- _i_d then the procedure has no effect.
-
- The purpose of file handlers is to enable an application to
- respond to X events and other events while waiting for files
- to become ready for I/O. For this to work correctly, the
- application must use non-blocking I/O operations on the
- files for which handlers are declared. Otherwise the appli-
- cation may be put to sleep if it specifies too large an
- input or output buffer; while waiting for the I/O to com-
- plete the application won't be able to service other events.
- In BSD-based UNIX systems, non-blocking I/O can be specified
- for a file using the fcntl kernel call with the FNDELAY
- flag.
-
-
- KEYWORDS
- callback, file, handler
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tk 2
-
-
-
-